const inquirer = require('inquirer')

const quesList = [
  {
    type: 'input',
    name: 'username',
    message: '请输入你的用户名',
    // default: 'lbr',
    validate(val) {
      if (!val) {
        return '当前为必填'
      }
      return true
    }
  },
  {
    type: "confirm",
    name: 'isInstall',
    message: '是否执行下载'
  },
  {
    type: "list",
    name: 'method',
    choices: ['npm', 'cnpm', 'yarn'],
    message: '选择下载方式',
    when(val) {
      return val.isInstall
    }
  },
  {
    type: 'checkbox',
    choices: ['eslint', 'vuex', 'vue-router', 'react', 'react-dom'],
    name: 'feature',
    pageSize: 10,
    message: '选择初始化安装的功能'
  }
]

inquirer.prompt(quesList).then(answer => console.log(answer))